home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
uartbug.zip
/
UART.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-03-09
|
28KB
|
684 lines
interrupts segment at 0h ;interrupt table segment
org 9h*4
keyboard_int dw 2 dup (?) ;interrupt 9 vector
interrupts ends
rom_bios_data segment at 40h ;ROM BIOS data area segment
org 0h
com1base dw ?
com2base dw ? ;base addresses for com1 and com2
org 60h
cursor_mode dw ? ;starting and ending cursor scan lines
rom_bios_data ends
rom segment at 0F000h ;ROM segment
org 0FFFEh
machine_id db ? ;ID byte identifies machine as PCjr or other
rom ends
code segment para public 'code' ;code segment
assume cs:code
org 100h
begin: jmp initialize ;goto initialization routine
com1 dw ?
com2 dw ? ;local storage for com1 and com2 base addresses
adrs dw ? ;current port address
byteout db 0 ;byte to be sent when rgt arrow key pressed
column_count dw ? ;width of window in columns
cursor_type dw ? ;cursor scan line definition
cursor_pos dw ? ;position of cursor on entry to program
setup_status db 0 ;indicates if printer window is already active
display_mode dw ? ;current crt display mode
vpage equ this byte
page_no dw ? ;current displayed page
attribute1 db 4Fh ;window attribute bytes
attribute2 db 70h
display_table db 2Dh,29h ;display re-enable values for modes 2 and 3
video dw 0B800h,0B900h,0BA00h,0BB00h ;starting addresses of video
;memory for CGA pages 0 - 3
mono_video dw 0B000h ;video segment address for
;monochrome adapter
old_kb_int label dword
old_keyboard_int dw 2 dup (?) ;storage for old keyboard
;interrupt vector
;----------------------------------------------------------------------------
;Text of the Printer Setup Menu window.
;After initialization, text and attribute bytes are combined and stored
;in the WINDOW_TEXT area, and this area is used to store the contents of
;the screen that underlie the window when the window is called up.
;----------------------------------------------------------------------------
window_buffer label word
buffer_text db 201,26 dup (205),187
db 186,' COM1 UART REGISTERS ',186
db 199,26 dup (196),182
db 186,' RX/TX reg* = ',186
db 186,' Intrpt enbl*= ',186
db 186,' Intrpt ID = ',186
db 186,' Line ctl = ',186
db 186,' Modem ctl = ',186
db 186,' Line stat = ',186
db 186,' Modem stat = ',186
db 186,' *baud if MSB of LCR set ',186
db 199,26 dup (196),182
db 186,' PGup/dn slct com port ',186
db 186,' Up/down keys slct reg ',186
db 186,' Rgt arrow writes reg ',186
db 186,' Lft arrow reads reg ',186
db 186,' ESC to exit ',186
db 186,' BYTE TO SEND: 00 Hex ',186
db 200,26 dup (205),188
db 532 dup (?)
;Storage area for the combination of text and attribute bytes that
;form the window image.
window_bytes label byte
window_text dw 532 dup (?)
;---------------------------------------------------------------------------
;Execution comes here, to the main body of the program, when an interrupt 9
;is generated from the keyboard. Registers are saved, then the keypress is
;checked and compared to the key combination that activates the menu window.
;---------------------------------------------------------------------------
main proc near
sti ;enable software interrupts
push ax ;save all registers
push bx
push cx
push dx
push si
push di
push ds
push es
push ax ;save ax for call to old routine
in al,0A0h ;re-enable NMI on PCjr
pop ax ;restore ax
pushf ;simulate interrupt call to old keyboard routine
call old_kb_int ;call old routine
mov ah,2 ;check status of the shift keys
int 16h
cmp al,14 ;***** CTRL,ALT,LEFT SHFT = activate pop up
je do_program ;yes, then skip exit routine
;Exit routine is the common point of exit for all routines in the program.
exit: pop es
pop ds
pop di
pop si
pop dx
pop cx
pop bx
pop ax
iret
;Execution comes here when the proper key combination, Ctrl/Alt/LftShft, is
;pressed. First task is to check whether or not the window is already open.
do_program: push cs ;set es and ds to the code segment
pop ds
push cs
pop es
cmp setup_status,0 ;is the window already open?
jne exit ;yes, then ignore request
;----------------------------------------------------------------------------
;Check current video mode. If it's mode 2, 3, or 7, then set the window
;status flag, store the mode number and page number, save the cursor type,
;and hide the cursor. If any other display mode is active instead, ignore
;the request and exit.
;----------------------------------------------------------------------------
mov ah,15 ;get page and mode numbers
int 10h ;al=mode, bh=page
cmp al,2 ;is crt now in an acceptable mode?
je prog0 ;yes, then continue
cmp al,3
je prog0
cmp al,7
je prog0
jmp exit ;no, then ignore request
prog0: mov setup_status,1 ;set status flag to indicate
;that window is active
mov ah,0 ;save mode number
mov display_mode,ax
push bx
mov bl,bh ;save page number for color displays
mov bh,0
mov page_no,bx
pop bx
mov ah,3 ;get cursor type
int 10h
mov cursor_type,cx ;save it
mov cursor_pos,dx ;save cursor position
mov ah,1 ;hide the cursor until later
mov ch,20h
int 10h
;Preparatory routines are completed. Now open the window by first saving the
;contents of video memory beneath the window and then writing the window text
;directly to memory.
mov bx,page_no ;use bx as index into video segment
;address table
cmp display_mode,7 ;manually adjust index for monochrome